/*
...params
------
[itme_type, img_src, script_name, text]
item_type : separator, img_only, text_only, img_text

Demo:
------
var panel1ToolbarItems = [
    ['img_only', 'images/platform/panel/arrow_refresh_small.png', 'refresh', '']
];
var panel1TitleItems = [
    ['img_text', 'images/platform/panel/bullet_arrow_down.png', 'setShowHide', '人员详细信息']
];
*/
function buildPanel1(panel) {
    var panel1Html = "";
    // panel head
    panel1Html += "<div class='panel1_h_left'><div class='panel1_h_right'><div class='panel1_h_middle'>";
    panel1Html += "<div class='panel1_head_title'></div>";
    panel1Html += "<div class='panel1_head_tool_item'></div>";
    panel1Html += "<div class='panel1_head_clear'></div>";
    panel1Html += "</div></div></div>";
    // panel body
    panel1Html += "<div class='panel1_c_left'><div class='panel1_c_right'><div class='panel1_c_middle'>";
    panel1Html += "<div id='" + panel.panelId + "_content'></div>";
    panel1Html += "</div></div></div>";
    // panel foot
    panel1Html += "<div class='panel1_f_left'><div class='panel1_f_right'><div class='panel1_f_middle'></div></div></div>";

    //
    $("#" + panel.panelId).html(panel1Html);

    //
    setPanel1Title(panel.panelId, panel.titleItems);
    setPanel1ToolbarItem(panel.panelId, panel.toolbarItems);
}

function setPanel1ToolbarItem(divId, params) {
    var resultStr = getPanel1ToolbarItemsHtml(params);
    $("#" + divId + " .panel1_head_tool_item").html(resultStr);
}

function setPanel1Title(divId, params) {
    var resultStr = getPanel1ToolbarItemsHtml(params);
    $("#" + divId + " .panel1_head_title").html(resultStr);
}

function getPanel1ToolbarItemsHtml(params) {
    var imgRelateLocation = "style/powerhua/platform/panel/images/";
    var resultStr = "";
    for(var i = 0; i < params.length; i++) {
        var param = params[i];
        if(param[0] == "img_text") {
            resultStr += "<img src=\"" + imgRelateLocation + param[1] + "\""
            + " alt=\"" + param[3] + "\""
            + " onclick=\"javascript:" + param[2] + ";\"> ";
            resultStr += "<a href=\"#\""
            + " onclick=\"javascript:" + param[2] + ";\">"
            + param[3] + "</a>";
        } else if(param[0] == "img_only") {
            resultStr += "<img src=\"" + imgRelateLocation + param[1] + "\""
            + " alt=\"" + param[3] + "\""
            + " onclick=\"javascript:" + param[2] + ";\">";
        } else if(param[0] == "text_only") {
            resultStr += "<a href=\"#\""
            + " onclick=\"javascript:" + param[2] + ";\">"
            + param[3] + "</a>";
        } else if(param[0] == "separator") {
            resultStr += "<img class=\"separator\" src=\"" + imgRelateLocation + param[1] + "\""
            + " >";
        }
    }
    return resultStr;
}